"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.WidgetVxeNumberInputViewComponent = void 0;
var _vue = require("vue");
var _use = require("../../form-design/src/use");
var _formItem = _interopRequireDefault(require("../../form/src/form-item"));
var _numberInput = _interopRequireDefault(require("../../number-input/src/number-input"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const WidgetVxeNumberInputViewComponent = exports.WidgetVxeNumberInputViewComponent = (0, _vue.defineComponent)({
  props: {
    renderOpts: {
      type: Object,
      default: () => ({})
    },
    renderParams: {
      type: Object,
      default: () => ({})
    }
  },
  emits: [],
  setup(props) {
    const $xeFormView = (0, _vue.inject)('$xeFormView', null);
    const {
      computeKebabCaseName
    } = (0, _use.useWidgetName)(props);
    const changeEvent = () => {
      const {
        renderParams
      } = props;
      const {
        widget
      } = renderParams;
      if ($xeFormView) {
        const itemValue = $xeFormView ? $xeFormView.getItemValue(widget) : null;
        $xeFormView.updateWidgetStatus(widget, itemValue);
      }
    };
    return () => {
      const {
        renderParams
      } = props;
      const {
        widget
      } = renderParams;
      const {
        options
      } = widget;
      const kebabCaseName = computeKebabCaseName.value;
      return (0, _vue.h)(_formItem.default, {
        class: ['vxe-form-design--widget-render-form-item', `widget-${kebabCaseName}`],
        title: widget.title,
        field: widget.field,
        itemRender: {}
      }, {
        default() {
          return (0, _vue.h)(_numberInput.default, {
            modelValue: $xeFormView ? $xeFormView.getItemValue(widget) : null,
            placeholder: options.placeholder,
            onChange: changeEvent,
            'onUpdate:modelValue'(val) {
              if ($xeFormView) {
                $xeFormView.setItemValue(widget, val);
              }
            }
          });
        }
      });
    };
  }
});